<template>
  <div class="page-view">
    <view>
      <uiInput placeholder="设置邮箱地址" v-model="email"></uiInput>
    </view>
    <view class="ui-txt txt-caption-sm ui-m-t-sm ui-p-h">电子邮箱</view>
    <view class="ui-m-t ui-p-h">
      <uiButton type="primary" :disabled="!email" @click="submitUpdateInfo">保存</uiButton>
    </view>
  </div>
</template>

<script>
import uiInput from "@/components/base/input/index";
import uiButton from "@/components/base/button/index";

import { updateUserInfoByUserIdAPI } from "@/api/base/user.js";
import { isEmail } from "@/utils/validate/email.js";
export default {
  name: "profileEmailModify",
  components: {
    uiInput,
    uiButton
  },
  data() {
    return {
      email: "",
      updateIsDiabled: true
    };
  },
  created() {},
  mounted() {},
  methods: {
    submitUpdateInfo() {
      if (!this.email) {
        return;
      }

      if (!isEmail(this.email)) {
        this.$toast.fail(`邮箱格式不正确`);
        return;
      }

      let params = {
        email: this.email
      };
      updateUserInfoByUserIdAPI(this.userInfo).then(
        ({ respCode, respMsg, result }) => {
          if (respCode == 0) {
            this.$toast({
              message: `信息修改成功`,
              width: "9rem",
              time: "2000",
              position: "middle",
              type: "text"
            });
            this.originData();
          }
        }
      );
    }
  }
};
</script>

<style scoped lang="scss" >
</style>
